// 采购订单管理

import axios from "@/api/axios";
let organizationNo = sessionStorage.getItem("organizationNo")
export default {
  queryPageByCondition(param) {
    param.entity.organizationNo = organizationNo;
    return axios.post("/v3/purchase/purchaseOrder/queryPageByCondition", param);
  },
  queryByCondition() {
    return axios.get(`/v3/purchase/purchaseOrder/queryNoyByCondition?no=${organizationNo}`);
  },
  add(param) {
    return axios.post("/v3/purchase/purchaseOrder/add", {
      ...param,
      organizationNo: sessionStorage.organizationNo
    });
  },
  edit(param) {
    return axios.post("/v3/purchase/purchaseOrder/edit", param);
  },
  // 批量刪除
  delList(list) {
    return axios.post(`/v3/purchase/purchaseOrder/delListByNo`, {
      noList: list
    })
  },
  // 修改订单审核状态
  updateAuditStatus(param) {
    return axios.post("/v3/purchase/purchaseOrder/updateAuditStatus", param);
  },
  // 修改订单完成状态
  updateCompleteStatus(param) {
    return axios.post("/v3/purchase/purchaseOrder/updateCompleteStatus", param);
  },
  queryByOrderNo(no) {
    return axios.post(`/v3/purchase/purchaseOrderGoods/queryByCondition`, {
      purchaseOrderNo: no
    })
  },

  // 分頁查詢
  getSellOrderList(param) {
    return axios.post("/purchaseOrder/queryPageList", param)
  },
  getPurchaseOrderList(param) {
    return axios.post("/purchaseOrderItemMapper/queryPageList", {
      page: param.page,
      size: param.size,
      sort: "timestamp",
      entity: {
        // organizationNo: sessionStorage.organizationNo,
        employeeId: param.employeeId
      }
    })
  },
  // 添加
  addSellOrderInfo(formData) {
    formData.organizationNo = sessionStorage.organizationNo;
    return axios.post("/purchaseOrder/add", formData)
  },
  // 批量刪除
  delSellOrderInfo(list) {
    return axios.post("/purchaseOrder/delList2", { purchaseOrderIdList: list })
  },
  delSellOrderInfos(purchaseOrderId) {
    return axios.get(`/purchaseOrder/del/${purchaseOrderId}`)
  },
  // 修改
  editSellOrderInfo(formData) {
    var organizationNo = sessionStorage.getItem('organizationNo');
    formData.organizationNo = JSON.parse(organizationNo);
    return axios.post("/purchaseOrder/edit", formData)
  },
  // 修改入库 订单状态
  editStatusPurchaseOrderManageInfo(formData) {
    return axios.post("purchaseOrder/editStatus", formData)
  },
  queryAllSellOrder(e) {
    return axios.post(`/v3/purchase/purchaseOrder/queryByCondition`, { status: e })
  }
}
// // 添加
// const add = data => {
//   console.log({ ...data });
//   return axios.post("/purchaseOrder/add", { ...data });
// };

// // 删除
// const del = purchaseOrderId =>
//   axios.get(`/purchaseOrder/del/${purchaseOrderId}`);

// // 批量删除
// const delList = idList =>
//   axios.post("/purchaseOrder/delList2", {
//     purchaseOrderIdList: idList
//   });

// // 修改
// const update = data => axios.post("/purchaseOrder/edit", { ...data });

// // 主键查询
// const search = purchaseOrderId =>
//   axios.get(`/purchaseOrder/query/${purchaseOrderId}`);

// // 分页查询
// const searchPage = ({ page, size, endTime, startTime, inputTypeId }) =>
//   axios.post("/purchaseOrder/queryPageList", {
//     // 查询条件
//     entity: {
//       endTime,
//       inputTypeId,
//       startTime
//     },
//     page,
//     size
//   });

// export { add, del, delList, update, search, searchPage };
